package com.tnovoselec.android.feed.handler.resultholders;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.tnovoselec.android.feed.handler.entity.ChannelDto;


public class ChannelsResultHolder {

    private static Map<String, List<ChannelDto>> MAP_RESULT = new HashMap<String, List<ChannelDto>>();

    private ChannelsResultHolder() {
	super();
    }

    public static void init(String url, List<ChannelDto> items) {
	MAP_RESULT.put(url, items);
    }

    public static void clear() {
	ChannelsResultHolder.MAP_RESULT.clear();
    }

    public static List<ChannelDto> getItemsByUrl(String url) {
	return MAP_RESULT.get(url);
    }

    public static ChannelDto getById(String id) {
	for (Entry<String, List<ChannelDto>> entry : MAP_RESULT.entrySet()) {
	    for (ChannelDto channel : entry.getValue()) {
		if (channel.getChannelId().equals(id)) {
		    return channel;
		}
	    }
	}
	return null;
    }

}
